<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <style>
        * {
            margin: 0px;
            padding: 0px;
        }

        div {
            width: 200px;
            height: 300px;
            background-color: green;
            float: left;
            margin-left: 20px;
            border: 2px solid green;
        }

        
    
    </style>
    <title>Highlight the DIVs</title>
</head>
<body>
    <div>DIV1</div>
    <div>DIV2</div>
    <div>DIV3</div>
    <div>DIV4</div>
    <div>DIV5</div>


    <script>
        var objs = document.getElementsByTagName("div");

        for(var i=0; i< objs.length; i++){
            
            // When mouse over
            objs[i].onmouseover = function(){
                this.style.border = "2px solid red";
            };

            // When mouse out
            objs[i].onmouseout = function(){
                this.style.border = "";
            };
        }
    
    
    </script>
</body>
</html>